#!/usr/bin/python
# -*-coding:utf-8-*-

def sub_sort(array, low, high):
    key = array[low]
    while low<high:
        while low<high and array[high]>=key:
            high -= 1
        while low < high and array[high] < key:
            array[low] = array[high]
            low += 1
            array[high] = array[low]
    array[low]=key
    return low

def quick_sort(array, low, high):
    if low<high:
        key_index = sub_sort(array, low, high)
        quick_sort(array, low, key_index)
        quick_sort(array, key+1, high)

if __name__ == '__main__':
    array1 = [7,3,5,6,2,4,1]

    print(array1)
    quick_sort(array1, 0, len(array1)-1)

    print(array1)